/*  This file is part of YATracker.
    YATracker is free software: you can redistribute it and/or modify it under the terms
of the GNU Lesser General Public License as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.
    YATracker is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
    You should have received a copy of the GNU Lesser General Public License along with
YATracker. If not, see <http://www.gnu.org/licenses/>. */

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QFile>

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow {
    Q_OBJECT
public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

protected:
    void changeEvent(QEvent *e);

private:
    Ui::MainWindow *ui;

private:
    bool downloadStarted;
    bool readyToStart;
    quint32 tileMinX, tileMaxX, tileMinY, tileMaxY, tileZoom;
    int tilesCount, tilesDone;
    QString mapFileName;
    QStringList tileUrls;
    QNetworkAccessManager manager;
    QNetworkReply *reply;
    QFile mapFile;

private:
    void calculateTiles();
    void downloadStart();
    void downloadStop();
    void startDownload(QString );

private slots:
    void on_comboBoxZoom_currentIndexChanged(QString );
    void downloadFinished(QNetworkReply *);
    void on_lineEditMaxLon_textChanged(QString );
    void on_lineEditMaxLat_textChanged(QString );
    void on_lineEditMinLon_textChanged(QString );
    void on_lineEditMinLat_textChanged(QString );
    void on_pushButtonMapFileBrowse_clicked();
    void on_pushButtonDownload_clicked();
    void on_lineEditUrl_textChanged(QString );
};

#endif // MAINWINDOW_H
